<?php
define('Copyright', 'Author QQ: 765858558');
define('ROOT_PATH', $_SERVER["DOCUMENT_ROOT"].'/');
include_once ROOT_PATH.'Admin/ExistUser.php';
include_once ROOT_PATH.'Admin/config/AdminConfig.php';
//include_once ROOT_PATH.'classed/MysqlData_Bak.php';
global $Users, $ConfigModel, $BakPassWord;
markPos("后台-后台备份");
if ($Users[0]['g_login_id'] != 89) exit;

if (isset($Users[0]['g_lock_1_7'])){
	if ($Users[0]['g_lock_1_7'] !=1) 
		exit(back('您的權限不足！'));
}
$db=new DB();
$result = $db->query("SELECT `g_id`, `g_qishu` FROM `g_history` ORDER BY g_qishu DESC LIMIT 84 ", 1);
$resultcq = $db->query("SELECT `g_id`, `g_qishu` FROM `g_history2` ORDER BY g_qishu DESC LIMIT 120 ", 1);
$resultpk = $db->query("SELECT `g_id`, `g_qishu` FROM `g_history6` ORDER BY g_qishu DESC LIMIT 179 ", 1);
$resultjs = $db->query("SELECT `g_id`, `g_qishu` FROM `g_history7` ORDER BY g_qishu DESC LIMIT 82 ", 1);
$resultkl8 = $db->query("SELECT `g_id`, `g_qishu` FROM `g_history8` ORDER BY g_qishu DESC LIMIT 179 ", 1);
$resultxyft = $db->query("SELECT `g_id`, `g_qishu` FROM `g_history4` ORDER BY g_qishu DESC LIMIT 180 ", 1);
$resultnc = $db->query("SELECT `g_id`, `g_qishu` FROM `g_history9` ORDER BY g_qishu DESC LIMIT 97 ", 1);
$MemberList = $userModel->GetMemberAll();
  
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php echo $oncontextmenu?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="/Css/common.css" rel="stylesheet" type="text/css" />
<link href="/Css/Style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/Common.js"></script>
<script type="text/javascript" src="/js/PublicData.js"></script>
<script type="text/javascript" src="/js/Forbid.js"></script>
<title></title>
</head>
<body onselectstart="return false">
<table border="0" cellspacing="0" cellpadding="0" class="Main">
  <tr>
    <td class="Main_top_left"></td>
    <td background="/Css/tab_05.gif"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="25" align="right"><img style="margin-right:5px" src="/Css/tb.gif" width="16" height="16" alt="" /></td>
          <td class="Main_Title">報表備份</td>
        </tr>
      </table></td>
    <td class="Main_top_right"></td>
  </tr>
  <tr>
    <td class="Main_left"></td>
    <td class="Main_conter"><!-- strat -->
      
      <table border="0" cellspacing="0" cellpadding="0" class="Man_Conter az rc">
        <form id="myForm" action="/Xml/Bak.php" method="post">
          <tr class="Conter_top">
            <th colspan="2" style="color:#000">報表備份</th>
          </tr>
    <!--  <tr>
            <td height="36" class="t_Edit_caption">廣東快樂十分</td>
            <td class="t_Edit_td"><select name="GD" id="GD">
                <option value="0">--- 選擇期數 ---</option>
                <option value="1">--- 所有期數 ---</option>
                <?php for ($i=0; $i<count($result); $i++){?>
                <option value='<?php echo $result[$i]['g_qishu']?>'><?php echo $result[$i]['g_qishu']?> 期</option>
                <?php }?>
              </select></td>
          </tr>
          <tr>
            <td height="36" class="t_Edit_caption">重慶時時彩</td>
            <td class="t_Edit_td"><select name="CQ" id="CQ">
                <option value="0">--- 選擇期數 ---</option>
                <option value="1">--- 所有期數 ---</option>
                <?php for ($i=0; $i<count($resultcq); $i++){?>
                <option value='<?php echo $resultcq[$i]['g_qishu']?>'><?php echo $resultcq[$i]['g_qishu']?> 期</option>
                <?php }?>
              </select></td>
          </tr>
          <tr>
            <td height="36" class="t_Edit_caption">北京賽車PK10</td>
            <td class="t_Edit_td"><select name="BJ" id="BJ">
                <option value="0">--- 選擇期數 ---</option>
                <option value="1">--- 所有期數 ---</option>
                <?php for ($i=0; $i<count($resultpk); $i++){?>
                <option value='<?php echo $resultpk[$i]['g_qishu']?>'><?php echo $resultpk[$i]['g_qishu']?> 期</option>
                <?php }?>
              </select></td>
          </tr>
          <tr>
            <td height="36" class="t_Edit_caption">江苏骰寶</td>
            <td class="t_Edit_td"><select name="JS" id="JS">
                <option value="0">--- 選擇期數 ---</option>
                <option value="1">--- 所有期數 ---</option>
                <?php for ($i=0; $i<count($resultjs); $i++){?>
                <option value='<?php echo $resultjs[$i]['g_qishu']?>'><?php echo $resultjs[$i]['g_qishu']?> 期</option>
                <?php }?>
              </select></td>
          </tr>
          <tr>
            <td height="36" class="t_Edit_caption">快樂8</td>
            <td class="t_Edit_td"><select name="KL8" id="KL8">
                <option value="0">--- 選擇期數 ---</option>
                <option value="1">--- 所有期數 ---</option>
                <?php for ($i=0; $i<count($resultkl8); $i++){?>
                <option value='<?php echo $resultkl8[$i]['g_qishu']?>'><?php echo $resultkl8[$i]['g_qishu']?> 期</option>
                <?php }?>
              </select></td>
          </tr>
          <tr>
            <td height="36" class="t_Edit_caption">幸运飞艇</td>
            <td class="t_Edit_td"><select name="XYFT" id="XYFT">
                <option value="0">--- 選擇期數 ---</option>
                <option value="1">--- 所有期數 ---</option>
                <?php for ($i=0; $i<count($resultxyft); $i++){?>
                <option value='<?php echo $resultxyft[$i]['g_qishu']?>'><?php echo $resultxyft[$i]['g_qishu']?> 期</option>
                <?php }?>
              </select></td>
          </tr>
          <tr>
            <td height="36" class="t_Edit_caption">幸运农场</td>
            <td class="t_Edit_td"><select name="NC" id="NC">
                <option value="0">--- 選擇期數 ---</option>
                <option value="1">--- 所有期數 ---</option>
                <?php for ($i=0; $i<count($resultnc); $i++){?>
                <option value='<?php echo $resultnc[$i]['g_qishu']?>'><?php echo $resultnc[$i]['g_qishu']?> 期</option>
                <?php }?>
              </select></td>
          </tr>  -->
		  <tr>
            <td height="36" class="t_Edit_caption">帳號選擇</td>
            <td class="t_Edit_td"><select name="member" id="member">
                <option value="1">--- 所有會員 ---</option>
                <?php for ($i=0; $i<count($MemberList); $i++){?>
                <option value='<?php echo $MemberList[$i][0]?>'><?php echo $MemberList[$i][0]?></option>
                <?php }?>
              </select></td>
          </tr>
          <tr>
            <td height="36" class="t_Edit_caption">下載格式</td>
            <td class="t_Edit_td"><select name="upFormat" id="upFormat">
                <option value="1">Excel</option>
              </select></td>
          </tr>
          <tr>
            <td class="t_Edit_caption">備份說明</td>
            <td class="t_Edit_td" style="height:55px;color:green">“當天備份” 系統將在次日淩晨2點半后自動刪除，如有需要請自行保存<br />
              “所有夜间模式彩种” 淩晨註單算當天帳<br />
              “所有報表均為封盤后，開獎前，系統自動備份的未結算帳目”</td>
          </tr>
        </form>
      </table>
      
      <!-- end --></td>
    <td class="Main_right" width="5"></td>
  </tr>
  <tr>
    <td class="Main_bottom_left"></td>
    <td background="/Css/tab_19.gif" align="center"><span id="showr" class="red" style="display:none">報表生成中，請稍後...</span> <a href="#" id="upExcel" onclick="openwin(this)" target="_blank" style="display:none">報表生成完成、點擊下載</a>
      <input type="button" name="submit" id="submit" onmouseover="this.className='input2_2'" onmouseout="this.className='input2'" class="input2" onclick="AccountBak()" value="下載" /></td>
    <td class="Main_bottom_right"></td>
  </tr>
</table>
</body>
</html>
<script language="javascript"> 

function AccountBak() {
    var c1 = $("#GD").val();
    var c2 = $("#CQ").val();
    var c3 = $("#BJ").val();
    var c4 = $("#JS").val();
	var c5 = $("#KL8").val();
	var c6 = $("#XYFT").val();
	var c7 = $("#NC").val();	
	var showr = $("#showr");
    var upFormat = $("#upFormat").val();
    var member = $("#member").val();
    var upExcel = $("#upExcel");
    var input = document.getElementsByTagName("input");
    var a = [], ret = 6;

    if (member == "0") {
        alert("抱歉！請選擇帳號。");
        return false;
    }

    if (c1 == "0" && c2 == "0" && c3 == "0" && c4 == "0" && c5 == "0" && c6 == "0" && c7 == "0") {
        alert("下載備份至少選擇一個彩種賬單！！！");
        return false;
    }
   
    document.getElementById("myForm").submit();
    return true;
}



</script>